package exception;

import lombok.Getter;

/**
 * @className: SoiRuntimeException
 * @author: ocxz1
 * @date: 2025/3/12 上午10:03
 * @Version: 1.0
 * @description: soi
 */
@Getter
public class SoiRuntimeException extends RuntimeException {

    private String message;

    private final Throwable cause;

    public SoiRuntimeException() {
        super();
        this.message = null;
        this.cause = null;
    }

    public SoiRuntimeException(Throwable cause) {
        super(cause);
        this.message = cause.getMessage();
        this.cause = cause;
    }

    public SoiRuntimeException(String message) {
        super(message);
        this.message = message;
        this.cause = null;
    }

    public SoiRuntimeException(String message,Throwable cause) {
        super(message,cause);
        this.message = message;
        this.cause = cause;
    }

    public SoiRuntimeException format(Object... params) {
        if (params == null || params.length == 0) {
            return this;
        }
        this.message = String.format(message.replaceAll("\\{}","%s"),params);
        return this;
    }
}
